package com.permission.model;

import com.fasterxml.jackson.annotation.*;
import com.solution.framework.model.BaseBean;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;

/**
* Created with generator tools.
* User: sunguangzhu
* DateTime:2014-04-28 09:39:13
*/
@Entity
@Table(name = "t_p_dept")
public class PDept extends BaseBean implements java.io.Serializable {

/**
* 名称
*/
private java.lang.String name;

/**
* 上级部门
*/
private  com.permission.model.PDept parent;

/**
* 用户集合
*/
private java.util.Set<com.permission.model.PUser> pUsers;

/** default constructor */
public PDept() {
}

/**
* full constructor
* @param name
* @param parent
* @param pUsers
*/
public PDept(java.lang.String name, com.permission.model.PDept parent,java.util.Set<com.permission.model.PUser> pUsers) {
this.name=name;
this.parent=parent;
this.pUsers=pUsers;
}

/**
*  getter
*/
    @Column
public java.lang.String getName() {
return this.name;
}

/**
* setter
* @param name
*/
public void setName(java.lang.String name) {
this.name = name;
}

/**
*  getter
*/
    @JsonManagedReference
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "parent_id")
    @NotFound(action = NotFoundAction.IGNORE)
public  com.permission.model.PDept getParent() {
return this.parent;
}

/**
* setter
* @param parent
*/
public void setParent( com.permission.model.PDept parent) {
this.parent = parent;
}

/**
*  getter
*/
    @JsonBackReference
    @OneToMany(fetch = FetchType.LAZY, mappedBy = "PDept")
public java.util.Set<com.permission.model.PUser> getPUsers() {
return this.pUsers;
}

/**
* setter
* @param pUsers
*/
public void setPUsers(java.util.Set<com.permission.model.PUser> pUsers) {
this.pUsers = pUsers;
}

}
